package com.ehsunbehravesh.varzesh3.net;

import java.awt.image.BufferedImage;
import java.net.URL;
import javax.imageio.ImageIO;

public class Newspaper
        implements Runnable {

  private String title;
  private String image;
  private boolean loaded;
  private BufferedImage img;

  public Newspaper(String title, String image) {
    this.title = title;
    this.image = image;
  }

  public void run() {
    while (!this.loaded) {
      try {
        this.img = ImageIO.read(new URL(this.image));
        this.loaded = true;
      } catch (Exception ex) {
        System.out.println(ex.getMessage());
      }
    }
  }

  public String getTitle() {
    return this.title;
  }

  public String getImage() {
    return this.image;
  }

  public boolean loaded() {
    return this.loaded;
  }

  public BufferedImage getImg() {
    return this.img;
  }
}